package com.example.park2212.user

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2212.R
import com.example.park2212.databinding.ActivityRegisterBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/user/RegisterActivity")
class RegisterActivity : BaseActivity<ActivityRegisterBinding,UserViewModel>() {
    override fun initView() {
        binding.btnRegister.setOnClickListener {
            val username = binding.etUsername.text.toString()
            val password = binding.etPassword.text.toString()
            viewModel.register(username, password)
        }

        binding.goLogin.setOnClickListener {
            ARouter.getInstance().build("/app/user/LoginActivity").navigation()
        }
    }

    override fun initData() {
        viewModel.registerSuccess.observe(this){
            ToastUtils.showLong("注册成功")
            ARouter.getInstance().build("/app/user/LoginActivity").navigation()
        }
    }

}